home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 June / EnigmA AMIGA RUN 19 (1997)(G.R. Edizioni)(IT)[!][issue 1997-06][EAR-CD III].iso / softwareupdate / system / atapi_pnp300 / developer_kit / cdinfo.c < prev    next >
C/C++ Source or Header  |  1996-09-17  |  5KB  |  126 lines

  1. /****************************************************************************
  2. *
  3. *
  4. *   $VER: CDInfo.c  1.0 (22 Jan 1996) by M_Campinoti CD++
  5. *
  6. *   $HISTORY:
  7. *
  8. *   22 Jan 1996 : 001.000 : First and Last release of an example that show
  9. *                           how to read and use the CDInfo structure.
  10. *                           Didactical use, so CLI only      :)
  11. *
  12. ****************************************************************************/
  13.  
  14. #include <proto/exec.h>
  15. #include <exec/devices.h>
  16. #include <exec/io.h>
  17. #include <stdio.h>
  18.  
  19. #include "atapi_cd.h"
  20.  
  21.  
  22. main (UBYTE argc,UBYTE **argv)
  23. {
  24.     struct IOStdReq      *ioreq = NULL ;
  25.     struct MsgPort       *reply = NULL ;
  26.     
  27.     struct CDInfo        Info;
  28.     
  29.     if (argc== 0) return;   /* it came from workbench ..... */
  30.  
  31.     if( reply = CreateMsgPort() )
  32.     {
  33.       if( ioreq = (struct IOStdReq *)
  34.              CreateIORequest(reply ,sizeof(struct  IOStdReq)) )
  35.       {
  36.         if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
  37.         {
  38.           ioreq->io_Command = CD_INFO;                /* Retrieve drive info.    */
  39.           ioreq->io_Data    = (APTR)&Info;            /* Here's where we want it */
  40.           ioreq->io_Length  = sizeof(struct CDInfo);  /* Return whole structure  */
  41.           
  42.           DoIO((struct IORequest*)ioreq);
  43.           
  44.           if (!ioreq->io_Error)                   /* Command succeeded        */
  45.           {
  46.            
  47.            /* Printout the contents of the CDInfo structure .. */
  48.            /* for more info see the file #include atapi_cd.h   */
  49.  
  50.             printf("------------------------------------------\n");
  51.             printf("| CDInfo ©1995-1996 by M.Campinoti  CD++ |\n");
  52.             printf("------------------------------------------\n");
  53.             printf("Some data maybe wrong, depends by accuracy\n");
  54.             printf("of your CDROM firmware !!!\n");
  55.             printf("------------------------------------------\n");
  56.  
  57.             printf("Audio Play Speed            : %d\n",Info.PlaySpeed);
  58.             printf("Date-rate of CD_READ        : %d\n",Info.ReadSpeed);
  59.             printf("Date-rate of CD_READXL      : %d\n",Info.ReadXLSpeed);
  60.             printf("Number of Bytes x Sectors   : %d\n",Info.SectorSize);
  61.             if(Info.XLECC) printf("CDXL ECC enabled.\n");
  62.             else           printf("CDXL ECC disabled.\n"); 
  63.             if(Info.EjectReset) printf("Reset on Eject enabled.\n");
  64.             else                printf("Reset on Eject disabled.\n");
  65.             printf("Max speed drive can handle  : %d\n",Info.MaxSpeed);
  66.             
  67.             switch(Info.AudioPrecision)
  68.             {
  69.                 case 0:
  70.                         printf("Audio Precision     : No Attenuator\n");
  71.                         break;
  72.                 case 1:
  73.                         printf("Audio Precision     : Mute only\n");
  74.                         break;
  75.                 default:
  76.                         printf("Audio Precision             : %d Levels\n",Info.AudioPrecision);
  77.                         break;
  78.             }
  79.             printf("------------------------------------------\n\n");
  80.             printf("---------------STATUS FLAGS---------------\n");
  81.            
  82.             if (Info.Status & CDSTSF_CLOSED) printf("Drive Door is Closed\n");
  83.             else                             printf("Drive Door is Open\n");
  84.  
  85.             if (Info.Status & CDSTSF_DISK) printf("A disk has been detected\n");
  86.             else                           printf("No disk has been detected\n");
  87.  
  88.             if (Info.Status & CDSTSF_SPIN) printf("Disk is Spinning\n");
  89.             else                           printf("Disk is not Spinning\n");
  90.  
  91.             if (Info.Status & CDSTSF_TOC) printf("TOC read, disk is valid\n");
  92.             else                          printf("TOC not read, no valid disk\n");
  93.  
  94.             if (Info.Status & CDSTSF_CDROM) printf("Track 1 contains CDROM data\n");
  95.             else                            printf("Track 1 no contains CDROM data\n");
  96.  
  97.             if (Info.Status & CDSTSF_PLAYING) printf("Audio is playing\n");
  98.             else                              printf("Audio not playing\n");
  99.  
  100.  
  101.             if (Info.Status & CDSTSF_PAUSED) printf("Pause Mode ON\n");
  102.             else                             printf("Pause Mode OFF\n");
  103.  
  104.             if (Info.Status & CDSTSF_SEARCH) printf("Search Mode (FFW/FREW)\n");
  105.             else                             printf("No Search Mode\n");
  106.  
  107.             if (Info.Status & CDSTSF_DIRECTION) printf("Search Direction: REVERSE\n");
  108.             else                                printf("Search Direction: FORWARD\n");
  109.            
  110.             printf("------------------------------------------\n\n");
  111.             
  112.           }
  113.           else printf("I/O error !\n");      /* analyze ioreq->io_Error to know what kind ... */
  114.                                              /* ... see atapi_cd.h for #defines of it !       */
  115.           
  116.           CloseDevice((struct IORequest *)ioreq) ;
  117.         }
  118.         
  119.         DeleteIORequest(ioreq) ;
  120.       }
  121.  
  122.       DeleteMsgPort(reply);
  123.     }
  124. }
  125.  
  126.